package com.msb.mall.seckill.schedule;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@EnableAsync
@EnableScheduling
@Component
public class ScheSeckill {

    /**
     * 默认定时任务是一个同步的任务，需要异步化
     * @EnableScheduling 开启定时任务
     * @Scheduled cron指定定时任务处理时间
     * @EnableAsync 开启异步
     * @Async 使用异步
     */
//    @Async
//    @Scheduled(cron = "0 0 2 * * *")
//    public void seckill(){
//        log.info("秒杀开始...");
//        try {
//            Thread.sleep(5000);
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }
//    }

}
